package com.smh.a05XmlDemo3;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.File;
import java.util.List;

public class XpathDemo2 {
    public static void main(String[] args) throws DocumentException {
        //相对路径(用的比较少)
        SAXReader saxReader = new SAXReader();
        File file = new File("day32-code\\src\\com\\smh\\a04XmlDemo2\\users.xml");
        Document document = saxReader.read(file);

        Element rootElement = document.getRootElement();

        List<Element> list = rootElement.selectNodes("./user/age");

        for (Element element : list) {
            System.out.println(element.getText());
        }


    }
}
